package com.example.psychologicalappointmentsystem.JpaRepository;

import com.example.psychologicalappointmentsystem.Entity.UserQuestionnaire;
import com.example.psychologicalappointmentsystem.Entity.UserQuestionnaireSummary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserQuestionnaireSummaryRepository extends JpaRepository<UserQuestionnaireSummary,Long>{

    @Query("select u from UserQuestionnaireSummary u where u.userId= ?1")
    UserQuestionnaireSummary find1UserId(Long UserId);

    @Modifying
    @Transactional
    @Query("update UserQuestionnaireSummary u set u.isCompleted = :#{#userQuestionnaireSummary.isCompleted}, u.anxietyLeverl = :#{#userQuestionnaireSummary.anxietyLeverl}, u.summary = :#{#userQuestionnaireSummary.summary} where u.userId= :#{#userQuestionnaireSummary.userId}")
    void update(@Param("userQuestionnaireSummary") UserQuestionnaireSummary userQuestionnaireSummary);

//    @Query("update UserQuestionnaireSummary set ")
//    @Modifying
//    int updateSummaryByUserId(Long UserId);
}
